package cn.edu.sdjzu.xg.eagle.mapper;

import cn.edu.sdjzu.xg.eagle.entities.Fees;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FeesMapper {

    @Insert("INSERT INTO Fees (fee_description, fee_amount, is_income, is_expense, reimbursement_time, report) " +
            "VALUES (#{feeDescription}, #{feeAmount}, #{isIncome}, #{isExpense}, #{reimbursementTime}, #{report})")
    @Options(useGeneratedKeys = true, keyProperty = "feeId", keyColumn = "fee_id")
    boolean addFee(Fees fee);

    @Delete("DELETE FROM Fees WHERE fee_id = #{feeId}")
    boolean deleteFee(Integer feeId);

    @Update("UPDATE Fees SET " +
            "fee_description = #{feeDescription}, " +
            "fee_amount = #{feeAmount}, " +
            "is_income = #{isIncome}, " +
            "is_expense = #{isExpense}, " +
            "reimbursement_time = #{reimbursementTime}, " +
            "report = #{report} " +
            "WHERE fee_id = #{feeId}")
    boolean updateFee(Fees fee);

    @Select("SELECT * FROM Fees WHERE fee_id = #{feeId}")
    Fees findFeeById(Integer feeId);

    @Select("SELECT * FROM Fees")
    List<Fees> findAllFees();
}